package view.component;

import java.awt.Graphics;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

import javax.swing.JPanel;

import view.renderer.Renderer;

public class ViewPort extends JPanel{
	
	private LinkedList<Renderer> renderers;
	
	public ViewPort(){
		super();
		renderers = new LinkedList<Renderer>();
	}
	
	
	@Override
	public void paint(Graphics g){
		super.paint(g);
		Iterator<Renderer> i = renderers.iterator();
		while(i.hasNext()){
			Renderer r = i.next();
			r.render(g);
		}
	}
	
	public void registerRenderer(Renderer r){
		renderers.add(r);
	}
	
	public void unregisterRenderer(Renderer r){
		renderers.remove(r);
	}
	
	public void resetRenderers(){
		renderers.clear();
	}
	
	public void registerAllRenderers(Collection<Renderer> c){
		renderers.addAll(c);
	}

}
